package com.yan.arrays;

import java.util.Random;

public class Test2 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int[] newArr = new int[3];
        int sum = 0;
        for (int i = 0; i < newArr.length; i++) {
            newArr[i] = arr[new Random().nextInt(10)];
        }
        for (int i = 0; i < newArr.length; i++) {
            sum += newArr[i];
        }
        for (int i = 0; i < newArr.length; i++) {
            System.out.print(newArr[i] + " ");
        }
        System.out.println();
        System.out.println("sum = " + sum);
    }
}
